#pragma once
#include "GRTXObj.h"
class GRTXTriangle;
class GRiObj;

// 对标外部的GRiObj
class GRTXMesh : public GRTXObject
{
private:
	std::vector<GSPtr<GRTXObject>> mTriangles;

public:
	std::vector<GSPtr<GRTXObject>> GetALLTriangles();

	virtual HitInfo Interset(const GRTXRay& ray) const override;

	// For Scene
	GRTXMesh(const GUSPtr<GRiObj>& pObj);

	virtual void SampleLight(GRiVertex& samplePos, float& pdf)const override;
	virtual bool IsLight() const override;

private:
	static GRiVertex TransformVertexToWorldSpace(const GRiVertex& vertex,
		const GMath::Matrix& world, 
		const GMath::Matrix& worldInvTranspose);
};

